﻿using System;
using System.Collections.Generic;
using System.Linq;
using Tisbi.LawFirm.DAL.Models;

namespace Tisbi.LawFirm.BL.Services.Implementation
{
    public class CaseServiceAgent : ServiceAgentBase<Cases>, ICaseServiceAgent
    {
        public void GetCasesByEmployee(int employeeId, Action<List<Cases>, Exception> completed)
        {
            // Declare error and result
            Exception error = null;
            List<Cases> items = null;

            // Set error or result
            try
            {
                items = DataBaseContext.Cases.Where(x => x.Employees != null && x.Employees.Id == employeeId).ToList();
            }
            catch (Exception ex)
            {
                error = ex;
            }

            // Invoke completion callback
            completed(items, error);
        }
    }
}
